use crate::query;


pub trait SqlId { fn val(&self)-> String; }
impl SqlId for i32 { fn val(&self) -> String { format!("{}", self) } }
impl SqlId for u32 { fn val(&self) -> String { format!("{}", self) } }
impl SqlId for String { fn val(&self) -> String { format!("'{}'", self) } }


pub trait SqlIn { fn val(&self, name:&str)-> String; }
impl SqlIn for Vec<i32> { 
    fn val(&self, name:&str) -> String {
        let vec = query::vec_num_to_vec_str::index(self.to_owned());
        format!("{} in ({})", name, vec.join(",")) 
    }
}
impl SqlIn for Vec<u32> { 
    fn val(&self, name:&str) -> String {
        let vec = query::vec_num_to_vec_str::index(self.to_owned());
        format!("{} in ({})", name, vec.join(",")) 
    }
}
impl SqlIn for Vec<String> { 
    fn val(&self, name:&str) -> String { 
        format!("find_in_set({},'{}')", name, self.join(",")) 
    }
}